Private Sub DrawBranch(ByVal thickness As Single, ByVal depth As Integer, ByVal X As Single, ByVal Y As Single, ByVal length As Single, ByVal length_scale As Single, ByVal theta As Single, ByVal dtheta As Single)
Dim x1 As Single
Dim y1 As Single
Dim status As Integer
' See where this branch should end.
x1 = X + length * Cos(theta)
y1 = Y + length * Sin(theta)
If thickness > 0 Then picCanvas.DrawWidth = thickness
picCanvas.Line (X, Y)-(x1, y1)
' If depth > 1, draw the attached branches.
If depth > 1 Then
DrawBranch thickness - 1, depth - 1, _
x1, y1, length * length_scale, _
length_scale, theta + dtheta, dtheta
DrawBranch thickness - 1, depth - 1, _
x1, y1, length * length_scale, _
length_scale, theta - dtheta, dtheta
End If
End Sub
Private Sub cmdGo_Click()
Dim taper As Integer
Dim depth As Integer
Dim dtheta As Single
Dim length As Single
Dim length_scale As Single
picCanvas.Cls
MousePointer = vbHourglass
DoEvents
If Not IsNumeric(txtDepth.Text) Then txtDepth.Text = "5"
depth = CInt(txtDepth.Text)
If Not IsNumeric(txtLengthScale.Text) Then txtLengthScale.Text = "0.75"
length_scale = CSng(txtLengthScale.Text)
If Not IsNumeric(txtDTheta.Text) Then txtDTheta.Text = "36"